import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'SingleLetter.dart';

class LetterPage extends StatelessWidget{

  String token;
  String title;  //信纸样式
  String letters="你还没写内容哦";   //信的内容
  var now = new DateTime.now();

  LetterPage(this.token,this.title);

  Widget build(BuildContext context){
    return Scaffold(
      appBar: new AppBar(
        title: new Text('记录此刻',style:TextStyle(color: Colors.black)),
        backgroundColor: Colors.white70,
        leading: IconButton(
          icon:Icon(Icons.arrow_back,color: Colors.black),
          onPressed: () {Navigator.pop(context);},
        ),
      ),
      body: Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                fit: BoxFit.cover,
                image: AssetImage(this.title)//获取信纸
            )
        ),
        child: Column(
          children: [
            Expanded(
                flex:1,
                child: SizedBox()),
            Expanded(
              flex: 2,
              child: Row(
                children: [
                  Expanded(
                    flex: 1,
                    child: Container(
                      margin: EdgeInsets.only(left: 10),
                      alignment: Alignment.centerLeft,
                      child: Text("亲爱的自己：",style: TextStyle(
                          fontSize: 16,
                          color: Colors.black
                      ),),
                    ),
                  ),
                  Expanded(
                      flex: 1,
                      child: Container(
                        alignment: Alignment.centerRight,
                        child: IconButton(
                          icon: Icon(Icons.email_rounded,color: Colors.black,),
                          onPressed: (){
                            Navigator.of(context).push(
                                MaterialPageRoute(builder: (context){
                                  return SingleLetter(this.token,this.title,this.letters);//把信的内容传到下一个界面
                                },)
                            );
                          },
                        ),
                      )
                  ),
                ],
              ),
            ),
            Expanded(
                flex: 19,
                child: Padding(
                  padding: EdgeInsets.all(10),
                  child: TextField(
                    maxLines: 15,
                    decoration: InputDecoration(
                        hintText: "不知道说些什么吗？那就记录下此刻的感受吧！",
                        border: OutlineInputBorder(
                            borderSide: BorderSide(
                                color: Colors.transparent
                            )
                        ),
                      contentPadding:EdgeInsets.all(10),
                      isCollapsed: true,
                    ),
                    onChanged: (value){
                      this.letters=value;     //获取信的内容
                    },
                  ),
                )),
            Expanded(
                flex: 4,
                child: Container(
                  alignment: Alignment.bottomRight,
                  margin: EdgeInsets.only(right: 10),
                  child: Column(
                    children: [
                      Expanded(
                          flex: 2,
                          child: Text("一个大可爱",textAlign: TextAlign.center,)),
                      Expanded(
                          flex: 1,
                          child: SizedBox()),
                      Expanded(
                          flex: 2,
                          child: Text("${now.year.toString()}-${now.month.toString().padLeft(2,'0')}-${now.day.
                          toString().padLeft(2,'0')} ${now.hour.toString().padLeft(2, '0')}:"
                              "${now.minute.toString().padLeft(2, '0')}:${now.second.toString().
                          padLeft(2, '0')}")
                      )
                    ],
                  ),
                )),
            Expanded(
                flex: 1,
                child: SizedBox())
          ],
        ),
      ),
    );
  }
}